using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.mall
{
[System.Serializable]
public  class Gift : MallItem
 {

    public string tag  = "";
     


    public const int TYPE_ID = 1540004896;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(9);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.INT | (2 << Tag.TAG_SHIFT));  os.WriteInt(itemId);  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.BEAN | (4 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Currency(presentPrice,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (5 << Tag.TAG_SHIFT));  os.WriteInt(originalPrice);  
         os.WriteSize(Tag.STRING | (6 << Tag.TAG_SHIFT));  os.WriteString(discount);  
         os.WriteSize(Tag.INT | (7 << Tag.TAG_SHIFT));  os.WriteInt(maximum);  
         os.WriteSize(Tag.BEAN | (8 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Limit(limit,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.STRING | (9 << Tag.TAG_SHIFT));  os.WriteString(tag);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.INT | (2 << Tag.TAG_SHIFT)):   itemId = os.ReadInt(); break;  
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.BEAN | (4 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); presentPrice = cfg.Extensions.unmarshal_compatible_cfg_condition_Currency(os); os = _oldOs; break; }   
             case (Tag.INT | (5 << Tag.TAG_SHIFT)):   originalPrice = os.ReadInt(); break;  
             case (Tag.STRING | (6 << Tag.TAG_SHIFT)):   discount = os.ReadString(); break;  
             case (Tag.INT | (7 << Tag.TAG_SHIFT)):   maximum = os.ReadInt(); break;  
             case (Tag.BEAN | (8 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); limit = cfg.Extensions.unmarshal_compatible_cfg_condition_Limit(os); os = _oldOs; break; }   
             case (Tag.STRING | (9 << Tag.TAG_SHIFT)):   tag = os.ReadString(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Gift");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("itemId"); ele.WriteAttributeString("id", "2"); ele.WriteInt(itemId); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "3"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("presentPrice"); ele.WriteAttributeString("id", "4"); cfg.Extensions.xml_marshal_cfg_condition_Currency(presentPrice,ele); ele.WriteEndElement();
         ele.WriteStartElement("originalPrice"); ele.WriteAttributeString("id", "5"); ele.WriteInt(originalPrice); ele.WriteEndElement();
         ele.WriteStartElement("discount"); ele.WriteAttributeString("id", "6"); ele.WriteString2(discount); ele.WriteEndElement();
         ele.WriteStartElement("maximum"); ele.WriteAttributeString("id", "7"); ele.WriteInt(maximum); ele.WriteEndElement();
         ele.WriteStartElement("limit"); ele.WriteAttributeString("id", "8"); cfg.Extensions.xml_marshal_cfg_condition_Limit(limit,ele); ele.WriteEndElement();
         ele.WriteStartElement("tag"); ele.WriteAttributeString("id", "9"); ele.WriteString2(tag); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  itemId = ele.ReadInt(); break; 
                 case 3:  name = ele.ReadString2(); break; 
                 case 4:  presentPrice = cfg.Extensions.xml_unmarshal_cfg_condition_Currency(ele); break; 
                 case 5:  originalPrice = ele.ReadInt(); break; 
                 case 6:  discount = ele.ReadString2(); break; 
                 case 7:  maximum = ele.ReadInt(); break; 
                 case 8:  limit = cfg.Extensions.xml_unmarshal_cfg_condition_Limit(ele); break; 
                 case 9:  tag = ele.ReadString2(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "item_id":  itemId = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "present_price":  presentPrice = cfg.Extensions.xml_unmarshal_cfg_condition_Currency(ele); break; 
                 case "original_price":  originalPrice = ele.ReadInt(); break; 
                 case "discount":  discount = ele.ReadString2(); break; 
                 case "maximum":  maximum = ele.ReadInt(); break; 
                 case "limit":  limit = cfg.Extensions.xml_unmarshal_cfg_condition_Limit(ele); break; 
                 case "tag":  tag = ele.ReadString2(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
